﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace SXFramWork.Core
{
    /// <summary>
    /// 设置权限(web)
    /// </summary>
    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
    public class PowerAttribute:Attribute
    {
        /// <summary>
        /// 设置权限名称
        /// </summary>
        /// <param name="title">权限名称</param>
        /// <param name="isBtn">是否生成按钮</param>
        /// <param name="btnName">按钮名称</param>
        /// <param name="pos">按钮位置  top/down</param>
        public PowerAttribute(string title,bool isBtn=true, string btnName="", string pos="top")
        {
            this.Title = title;
            this.IsButton =isBtn;
            //如果没有指定按钮名称 默认设置为title值
            this.BtnName = btnName.IsNull()?title:btnName;
            this.Pos = pos;
        }
        /// <summary>
        /// 设置权限名称
        /// </summary>
        /// <param name="title">权限名称</param>
        public PowerAttribute(string title)
        {
            this.Title = title;
            this.IsButton = false;
        }
        /// <summary>
        /// 权限按钮初始位置
        /// </summary>
        public string Pos { get; set; } = "top";
        /// <summary>
        /// 权限名称
        /// </summary>
        public string Title { get; set; }
        /// <summary>
        /// 唯一编码 如 "admin_sysuser_add"
        /// </summary>
        public string Code { get; set; }
        /// <summary>
        /// 所属菜单编码
        /// </summary>
        public string MenuCode { get; set; }
        /// <summary>
        /// 是否生成按钮
        /// </summary>
        public bool IsButton { get; set; }=false;
        /// <summary>
        /// 按钮名称
        /// </summary>
        public string BtnName { get; set; }
    }
}
